﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Icoders.MarketTracker.Data;
using Icoders.MarketTracker.Web.Lib.Services;
using StructureMap;

namespace Icoders.MarketTracker.Web.Lib.Util.Helper
{
    public static class Common
    {
        public static MvcHtmlString MyHost(this HtmlHelper helper)
        {
            string authority= helper.ViewContext.HttpContext.Request.Url.Authority;
            string scheme = helper.ViewContext.HttpContext.Request.Url.Scheme;
            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
            string webroot = urlHelper.Content("~");
            string urlformat = string.Format("{0}://{1}{2}", scheme, authority, webroot);
            return MvcHtmlString.Create(urlformat);
        }
        public static List<SelectListItem> GetClient(this HtmlHelper helper)
        {
            IDropDownService _dropDownService = ObjectFactory.GetInstance<IDropDownService>();
            var li = _dropDownService.GetAllClient();
           
            
            return li;
        }
        public static int GetClientIdFromCookies()
        {
            int clientId = 0;
            var cookie =HttpContext.Current.Request.Cookies["SelectedClient"];
            if (cookie != null)
            {
                int.TryParse(cookie.Value, out clientId);
            }
            return clientId;
        }
        public static bool IsKimfay(this HtmlHelper helper)
        {
#if(KIMFAY)
            return true;

#else
        return false;
#endif
        }
        public static bool IsBAT(this HtmlHelper helper)
        {
#if(BAT)
            return true;

#else
            return false;
#endif
        }

    }
}
